package getsubs;

import getsubs.model.*;
import getsubs.filenameguesser.RegExpGuesser;
import getsubs.jdkweb.JdkUrlOpener;
import getsubs.popnapisi.PopnSubtitleFinder;
import getsubs.popnapisi.TheRealWeb;
import getsubs.popnapisi.UrlOpener;
import getsubs.popnapisi.Web;
import java.io.File;
import java.io.IOException;

public class Main {

    public static void main(String[] args) throws IOException {
        SubDownloader downloader = new Main().createSubDownloader();

        for(String arg:args) {
            downloader.downloadSubtitlesFor(new File(arg));
        }
    }

    public SubDownloader createSubDownloader() {
        UrlOpener urlOpener = new JdkUrlOpener();
        Web web = new TheRealWeb(urlOpener);
        SubtitleFinder finder = new PopnSubtitleFinder("http://sub-titles.net/", 
                                                       web, urlOpener);
        EpisodeInfoGuesser guesser = new RegExpGuesser();
        return new SubDownloader(finder, guesser);
    }

}
